package com.example.windowdemo.window;

import android.content.Context;
import android.view.View;

/**
 * @author: njb
 * @date: 2023/7/31 23:49
 * @desc:
 */
public class FloatingWindow {
    private Window mWindow;
    private WindowManagerHelper mWindowManagerHelper;

    public FloatingWindow(Context context) {
        mWindow = new Window(context);
        mWindowManagerHelper = WindowManagerHelper.getInstance(context);
    }

    public void setFullScreen(boolean isFullScreen) {
        mWindow.setFullScreen(isFullScreen);
    }

    public void setTitleBar(boolean hasTitleBar) {
        mWindow.setTitleBar(hasTitleBar);
    }

    public void setSize(int width, int height) {
        mWindow.setSize(width, height);
    }

    public void setPosition(int x, int y) {
        mWindow.setPosition(x, y);
    }

    public void setGravity(int gravity) {
        mWindow.setGravity(gravity);
    }

    public void addView(View view) {
        mWindow.addView(view);
    }

    public void show() {
        mWindowManagerHelper.addView(mWindow.contentView, mWindow.layoutParams);
    }

    public void hide() {
        mWindowManagerHelper.removeView(mWindow.contentView);
    }
}
